<!DOCTYPE html>
<html lang="{{ .Site.LanguageCode }}">
{{ partial "head.html" . }}
<link rel="stylesheet" href="{{ "css/news.css" | relURL}}?t={{ mul 1000 (time now).Unix }}">
<div id="all">
    <header>
        {{ partial "nav.html" . }}
    </header>
    <div class="nav-mask hide"></div>
    <div class="news-card">

        <div id="content">
            <div class="container">
                <div class="row">
                    <div class="col-md-12">
                        <h1 class="recent-news">{{ i18n "NEWS_TITLE" }}</h1>
                        {{ $paginator := .Paginate (where .Data.Pages "Type" "news") }}
                        {{ range $paginator.Pages }}
                        <section class="post">
                            <div class="row">
                                <h3 class="fontHuaweiSans"><a href="{{ .Permalink }}" target="_blank">{{ .Title }}</a></h3>
                                <h5 class="author-category">
                                    {{ if isset .Params "author" }}
                                    <span>{{ .Params.author }}</span>
                                    <span class="line"></span>
                                    <span class="news-date">{{ .Date.Format .Site.Params.date_format }}</span>

                                    {{ end }}
                                </h5>
                                <p>{{ .Params.description }}</p>
                                <p class="view-more"><a href="{{ .Permalink }}" target="_blank">{{ i18n "MAIN_LIST_MORE" }} </a></p>
                            </div>
                        </section>
                        {{ end }}  
                          
                        <!-- 分页开始 -->
                        {{ $pag := $.Paginator }}
                        {{ if  gt $pag.TotalPages 1}} 
                        <ul class="pagination">
                            {{ if $pag.HasPrev }}
                                <li><a class='page-number' href="{{ $pag.Prev.URL }}">&larr; {{ i18n "newer" }}</a></li>
                            {{ end }}
                            
                            {{ $ellipsed := false }}
                            {{ $showldEllipse := false }}
                            {{ range $pag.Pagers }}
                                {{ $right := sub .TotalPages .PageNumber }}
                                {{ $showNumber := or (le .PageNumber  3) (eq $right 0) }}
                                {{ $showNumber := or $showNumber (and (gt .PageNumber (sub $pag.PageNumber 2)) (lt .PageNumber (add $pag.PageNumber 2)))  }}

                                {{ if $showNumber }}
                                        {{ $ellipsed = false }}
                                        {{ $showldEllipse = false }}
                                    {{ else }} 
                                        {{ $showldEllipse = not $ellipsed }}
                                        {{ $ellipsed = true }}
                                {{ end }}

                                {{ if $showNumber }}
                                <li class="{{ if eq . $pag }} active {{ end }}"><a class="page-number" href='{{ .URL }}'>{{ .PageNumber }}</a></li>
                                    {{ else if $showldEllipse }}
                                    <span class="space">&nbsp;&hellip;&nbsp;</span>
                                {{end}} 
                            {{end}} 
                            {{ if $pag.HasNext }}
                            <li><a class="page-number" href='{{ $pag.Next.URL }}'>{{ i18n "older" }} &rarr;</a></li>
                            {{ end }} 
                        </ul>
                        {{ end }}
                        <!-- 分页结束 -->

                    </div>
                </div>
            </div>

        </div>
    </div>
    {{ partial "footer.html" . }}
</div>
{{ partial "scripts.html" . }}

</html>